package de.hohenheim.modell;

import java.util.Vector;

public class Programmoptionen {
	Room room;
	Vector<Room> roomlist = new Vector<Room>(0);
	Package paket;
	Vector<Package> paketliste = new Vector<Package>(0);
	ForkTruck forktruck;
	Vector<ForkTruck> gabelstaplerliste = new Vector<ForkTruck>(0);
	
	
	public void addRaum(Room entry) {
		roomlist.add(entry);
	}
	
	public void addPaket(Package entry) {
		paketliste.add(entry);
	}
	
	public void addGabelstapler(ForkTruck entry) {
		gabelstaplerliste.add(entry);
	}
	
	public Vector<Room> getRoomlist() {
		return this.roomlist;
	}
	
	public Vector<Package> getPackages(String roomname) {
		Vector<Package> paketraumliste = new Vector<Package>();
		for(int i = 0; i < paketliste.size(); i++) {
			if (paketliste.elementAt(i).getStartraum().equals(roomname)) {
				paketraumliste.add(paketliste.elementAt(i));
			}
		}
		return paketraumliste;
	}
	
	public Vector<ForkTruck> getGabelstaplerliste() {
		return this.gabelstaplerliste;
	}
	
	public void ausgabe (Vector<Package> in) {
		for(int i = 0; i < in.size() ; i++) {
			System.out.println("aus " + in.elementAt(i).getPaketName());
		}
	}

	
	public Room getRoom(String nm) {
		for(int i=0; i < 1 + roomlist.size() - 1; i++) {
			if (roomlist.elementAt(i).name.equals(nm))
				room = roomlist.elementAt(i);
		}
		return room;
	}
	
	public ForkTruck getGabelstapler(int id) {
		for(int i=0; i < 1 + gabelstaplerliste.size() - 1; i++) {
			if (gabelstaplerliste.elementAt(i).gabelstaplerID == id)
				forktruck = gabelstaplerliste.elementAt(i);
		}
		return forktruck;
	}
	
	public Package getPaket(String name) {
		for(int i=0; i < 1 + paketliste.size() - 1; i++) {
			if (paketliste.elementAt(i).paketName.equals(name))
				paket = paketliste.elementAt(i);
		}
		return paket;
	}
	
	public void removeRaum(int index) {
		roomlist.remove(index);
	}
	
	public void removePaket(String name) {
		for(int i=0; i < 1 + paketliste.size() - 1; i++) {
			if (paketliste.elementAt(i).paketName.equals(name))
				paketliste.remove(i);
		}
	}
	
	public void changePaketLocation(Package entry, String room) {
		for(int i=0; i < 1 + paketliste.size() - 1; i++) {
			if (paketliste.elementAt(i).paketName.equals(entry.paketName)) {
				paketliste.remove(i);
				paketliste.add(new Package(entry.paketName ,room, entry.paketgewicht, entry.paketvolumen));
			}	
		}
	}
	
	public Vector<Package> getPaketliste () {
		return paketliste;
	}
	
}
